# -*- coding: utf-8 -*-
'''
@文件    :user.py
@说明    :
@时间    :2025/08/28 23:32:24
@作者    :浪晋
@版本    :1.0
'''

from tortoise import fields
from .base import BaseModel, TimestampMixin, DefaultFilterManager


class UserBaseModel(BaseModel, TimestampMixin):
    phone = fields.CharField(max_length=20, null=False, description="电话")
    nickname = fields.CharField(max_length=20, null=False, description="昵称")
    password = fields.CharField(max_length=128, null=True, description="密码")
    avatar = fields.CharField(max_length=255, null=True, description="头像")
    active = fields.BooleanField(default=True, description="是否激活")
    last_login_time = fields.DatetimeField(null=True, description="最后登录时间")
    last_login_ip = fields.CharField(max_length=128, null=True, description="最后登录Ip")
    class Meta:
        table = "tb_user_base"
        table_description = "用户基础表"
        manager = DefaultFilterManager()


class UserAuthModel(BaseModel, TimestampMixin):
    realName = fields.CharField(max_length=20, null=False, description="真实姓名")
    idCardNum = fields.CharField(max_length=20, null=False, description="身份证号")
    sex = fields.CharField(max_length=20, null=True, description="性别")
    nation = fields.CharField(max_length=20, null=True, description="民族")
    birthday = fields.CharField(max_length=20, null=True, description="生日")
    address = fields.CharField(max_length=255, null=True, description="住址")
    idCardUpPic = fields.CharField(max_length=255, null=False, description="身份证正面")
    idCardDownPic = fields.CharField(max_length=255, null=False, description="身份证反面")
    idCardHandPic = fields.CharField(max_length=255, null=True, description="手持身份证")
    user = fields.OneToOneField("models.UserBaseModel", related_name="auth", db_constraint=False, description="用户")
    class Meta:
        table = "tb_user_auth"
        table_description = "用户实名表"
        manager = DefaultFilterManager()